package com.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.api.common.jwt.TokenIgnore;
import com.api.common.reqres.Request;
import com.api.common.reqres.Response;
import com.api.model.request.AddUserRequest;
import com.api.model.request.BackstageUserLoginRequest;
import com.api.model.request.UpdatePasswdRequest;
import com.api.model.request.UpdateUserInfoRequest;
import com.api.model.response.BackstageUserLoginResponse;
import com.api.model.response.NullResponse;
import com.api.service.BackstageUserService;

import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 后台用户登陆
 * </p>
 *
 * @author cfp
 * @since 2019-10-21
 */
@TokenIgnore
@RestController
public class BackstageUserController {
	@Autowired
	private BackstageUserService backstageUserService;

	@ApiOperation(notes = "后台用户登陆", value = "后台用户登陆")
	@PostMapping(value = "/backstageUserLogin.do")
	public Response<BackstageUserLoginResponse> backstageUserLogin(
			@RequestBody Request<BackstageUserLoginRequest> request) throws Exception {
		return backstageUserService.backstageUserLogin(request);
	}

	@ApiOperation(notes = "修改密码", value = "修改密码")
	@PostMapping(value = "/updatePasswd.do")
	public Response<NullResponse> updatePasswd(@RequestBody Request<UpdatePasswdRequest> request) throws Exception {
		return backstageUserService.updatePasswd(request);
	}

	@ApiOperation(notes = "增加用户", value = "增加用户")
	@PostMapping(value = "/addUser.do")
	public Response<NullResponse> addUser(@RequestBody Request<AddUserRequest> request) throws Exception {
		return backstageUserService.addUser(request);
	}

	@ApiOperation(notes = "修改用户信息", value = "修改用户信息")
	@PostMapping(value = "/updateUserInfo.do")
	public Response<NullResponse> updateUserInfo(@RequestBody Request<UpdateUserInfoRequest> request) throws Exception {
		return backstageUserService.updateUserInfo(request);
	}
}
